
function starbar(id) {
	
	var pathName=window.document.location.pathname;
	var projectName=pathName.substring(0,pathName.substr(1).indexOf('/')+1); 
	var obj_img = document.getElementById(id).getElementsByTagName("img");
	
	for (var i = 0; i < obj_img.length; i++) {
		obj_img[i].index = i;
		
		obj_img[i].onmouseenter = function() {
			for (var j = 0; j < this.index + 1; j++) {
				obj_img[j].setAttribute("src", projectName+"/img/star_full.png");
			}
		}
		obj_img[i].onmouseleave = function() {
			for (var j = 0; j < this.index + 1; j++) {
				obj_img[j].setAttribute("src", projectName+"/img/star_none.png");
			}
		}
		
		obj_img[i].onclick = function() {
			
			//判断评价是满意度，把满意度值放到满意度的隐藏域中
			if("satisfaction" == id){
				$("#satisfactionComment").val(this.index+1);
			}
			//判断评价是送货速度，把送货速度放到送货速度的隐藏域中
			if("speed" == id){
				$("#speedComment").val(this.index+1);
			}
			//判断评价是商品包装，把商品包装值放到商品包装的隐藏域中
			if("decorate" == id){
				$("#decorateComment").val(this.index+1);
			}
			
			for (var j = 0; j < 5; j++) {
				
				if (j <= this.index) {
					obj_img[j].setAttribute("src",projectName+"/img/star_full.png");
					
				} else {
					obj_img[j].setAttribute("src",projectName+"/img/star_none.png");
					
				}
				obj_img[j].onmouseenter = null;
				obj_img[j].onmouseleave = null;
			}
		}
		
	}
/*	alert(this.index+"----")*/
}

starbar("satisfaction");
starbar("speed");
starbar("decorate");

var evalutes = document.getElementsByClassName("evalutes")[0].getElementsByTagName("span");
for (var i = 0; i < evalutes.length; i++) {
	evalutes[i].onclick = function() {
		if (!this.hasAttribute("class")) {
			this.className += "active"
		} else {
			this.removeAttribute("class");
			return false;
		}
	}
}
